﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Model.Entities;
using System.Web;
using Totoro.Core;
using Totoro.Passport;

using Totoro.ORMapping;
using NHibernate;
using NHibernate.Criterion;

namespace Bussiness
{
    /// <summary>
    /// 产品列表
    /// </summary>
    public class ProductOperation
    {
        private ProductOperation() { }

        public static readonly ProductOperation Instance = new ProductOperation(); 
             
        /// <summary>
        /// 获取所有菜单列表
        /// </summary>
        /// <returns></returns>
        public IList<Products> GetAllProduct()
        {
            IList<Products> lst = null;
            ISession session = NHHelper.GetCurrentSession();
            ICriteria cr = session.CreateCriteria<Products>();
            lst = cr.List<Products>();
            return lst; 
        }

        public void DeleteProductByID(string id)
        {
            ISession session = NHHelper.GetCurrentSession();
            ICriteria cr = session.CreateCriteria<Products>();
            Products p = (Products)session.Load(typeof(Products), id);
            session.Delete(p);
        }

        public void InsertProduct(Products p)
        {
            NHHelper.SaveOjb(p); 
        }

        
    }
}
